part of _;

extension on MainPage_Home_Category {
  Widget view_list() {
    return Container(
      width: 100,
      child: ListView.builder(
        physics: BouncingScrollPhysics(),
        padding: EdgeInsets.zero,
        itemCount: models.length,
        itemBuilder: (context, index) {
          var model = models[index];
          return YButton(
            onTap: () {
              models.forEach((element) => element.isSelect = false);
              model.isSelect = true;
              setState(() {});
            },
            color: model.isSelect ? Colors.white : Colors.transparent,
            child: Container(
              height: 50,
              alignment: Alignment.center,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  !model.isSelect ? YEmpty() : Container(width: 3, height: 15, margin: EdgeInsets.only(right: 5), color: YConfig.themeColor),
                  model.isSelect ? Text(model.title, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: YConfig.themeColor)) : Text(model.title),
                ],
              ),
            ),
          );
        },
      ),
    );
  }

  Widget view_main() {
    var column = 3;
    var space = 10.0;
    var imgSize = (yScreenSize().width - 100 - (column + 3) * space) / column - space;
    List<ShouYeFLModel_Group> groups = [];
    models.forEach((element) {
      if (element.isSelect) groups = element.groups;
    });
    return ListView.builder(
      physics: BouncingScrollPhysics(),
      padding: EdgeInsets.only(top: space),
      itemCount: groups.length,
      itemBuilder: (context, index) {
        var group = groups[index];
        return Card(
          elevation: 1,
          color: Colors.white,
          margin: EdgeInsets.fromLTRB(space, 0, space, space),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: EdgeInsets.only(left: 10, top: 10, bottom: 10),
                child: Text(group.title, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
              ),
              GridView.builder(
                primary: false,
                shrinkWrap: true,
                padding: EdgeInsets.zero,
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: column, mainAxisSpacing: 0, crossAxisSpacing: 0, childAspectRatio: 0.75),
                itemCount: group.items.length,
                itemBuilder: (context, index) {
                  var item = group.items[index];
                  return YButton(
                    onTap: () => AppUtils.goIntent(yPage, Enum_IntentType.GoProductList_content, params: {
                      "content": item.title,
                    }),
                    child: Padding(
                      padding: EdgeInsets.only(top: 15),
                      child: Column(
                        children: [
                          YImageCorner(imgSize, imgSize, item.img, imgSize / 2),
                          YSpacer(height: 10),
                          Text(item.title),
                        ],
                      ),
                    ),
                  );
                },
              ),
            ],
          ),
        );
      },
    );
  }
}
